package me.zk.practice1.s;

import java.util.Deque;
import java.util.LinkedList;
import java.util.Stack;

/**
 * @author zhangkai
 * @date 2023/7/13 14:58
 */
public class LS_Offer_30 {

    Deque<Integer> list;
    Deque<Integer> minList;
    public LS_Offer_30() {
        list = new LinkedList<>();
        minList = new LinkedList<>();
        minList.push(Integer.MAX_VALUE);
    }

    public void push(int x) {
        list.push(x);
        minList.push(Math.min(minList.peek(),x));

    }

    public void pop() {
        list.pop();
        minList.pop();

    }

    public int top() {
        return list.peek();
    }

    public int min() {
        return minList.peek();
    }

    public static void main(String[] args) {
        LS_Offer_30 minStack = new LS_Offer_30();
        minStack.push(-2);
        minStack.push(0);
        minStack.push(-3);
        System.out.println(minStack.min());
        minStack.pop();
        minStack.pop();
        System.out.println(minStack.top());
        System.out.println(minStack.min());

    }
}
